package com.principle.strategy.improve;

public abstract class Duck {
    //属性，策略接口
    FlyBehavior flyBehavior;
    QuackBehavior quackBehavior;
    //其他属性->策略接口

    abstract void display();
    public void quack(){
        if (quackBehavior!=null){
            quackBehavior.quack();
        }
    }
    public void swim(){
        System.out.println("鸭子会游泳");
    }
    public void fly(){
        if (flyBehavior!=null){
            flyBehavior.fly();
        }

    }
}
